﻿using Coldairarrow.Business.PersonalCenter;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.PersonalCenter;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.PersonalCenter
{
    [Route("/PersonalCenter/[controller]/[action]")]
    public class BTB_CollectionController : BaseApiController
    {
        #region DI

        public BTB_CollectionController(IBTB_CollectionBusiness bTB_CollectionBus)
        {
            _bTB_CollectionBus = bTB_CollectionBus;
        }

        IBTB_CollectionBusiness _bTB_CollectionBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<BTB_GoodsDto>> GetDataList(PageInput<BTB_GoodsDto> input)
        {
            return await _bTB_CollectionBus.GetDataListAsync(input);
        }
        #endregion

        #region 提交
        /// <summary>
        /// 添加或修改个人收藏
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task SaveData(BTB_Collection data)
        {
            if (data.id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _bTB_CollectionBus.AddDataAsync(data);
            }
            else
            {
                await _bTB_CollectionBus.UpdateDataAsync(data);
            }
        }
        /// <summary>
        /// 删除个人指定收藏
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _bTB_CollectionBus.DeleteDataAsync(ids);
        }
        /// <summary>
        /// 批量添加
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task BatchAdd(List<BTB_browse> data)
        {
            await _bTB_CollectionBus.BatchAdd(data);
        }
        #endregion
    }
}